#![allow(dead_code, mutable_transmutes, non_camel_case_types, non_snake_case, non_upper_case_globals, unused_assignments, unused_mut)]
extern crate libc;
use primary::alloc_testing::*;
use primary::compare_pointer::*;
use primary::compare_string::*;
use primary::compare_int::*;
use primary::hash_pointer::*;
use primary::hash_string::*;
use primary::hash_int::*;
extern "C" {
    fn __assert_fail(
        __assertion: *const libc::c_char,
        __file: *const libc::c_char,
        __line: libc::c_uint,
        __function: *const libc::c_char,
    ) -> !;
                    }
#[no_mangle]
pub extern "C" fn test_pointer_hash() {
    let mut array: [libc::c_int; 200] = [0; 200];
    let mut i: libc::c_int = 0;
    let mut j: libc::c_int = 0;

    while i < 200 {
        array[i as usize] = 0;
        i += 1;
    }

    i = 0;
    while i < 200 {
        j = i + 1;
        while j < 200 {
            let ptr_i = unsafe { array.as_mut_ptr().offset(i as isize) };
            let ptr_j = unsafe { array.as_mut_ptr().offset(j as isize) };
            unsafe {
                assert!(
                    pointer_hash(ptr_i as *mut libc::c_void)
                        != pointer_hash(ptr_j as *mut libc::c_void),
                    "pointer_hash(&array[i]) == pointer_hash(&array[j])"
                );
            }
            j += 1;
        }
        i += 1;
    }
}
#[no_mangle]
pub extern "C" fn test_int_hash() {
    let mut array: [libc::c_int; 200] = [0; 200];
    let mut i: libc::c_int = 0;
    let mut j: libc::c_int = 0;

    while i < 200 {
        array[i as usize] = i;
        i += 1;
    }

    i = 0;
    while i < 200 {
        j = i + 1;
        while j < 200 {
            let array_i = unsafe { &mut *array.as_mut_ptr().offset(i as isize) };
            let array_j = unsafe { &mut *array.as_mut_ptr().offset(j as isize) };
            assert_ne!(
                int_hash(array_i as *mut libc::c_int as *mut libc::c_void),
                int_hash(array_j as *mut libc::c_int as *mut libc::c_void),
                "int_hash(&array[i]) != int_hash(&array[j])"
            );
            j += 1;
        }
        i += 1;
    }

    i = 5000;
    j = 5000;
    let i_ptr = &mut i as *mut libc::c_int;
    let j_ptr = &mut j as *mut libc::c_int;
    assert_eq!(
        int_hash(i_ptr as *mut libc::c_void),
        int_hash(j_ptr as *mut libc::c_void),
        "int_hash(&i) == int_hash(&j)"
    );
}
#[no_mangle]
pub extern "C" fn test_string_hash() {
    let mut test1: [libc::c_char; 15] = unsafe {
        *::core::mem::transmute::<&[u8; 15], &mut [libc::c_char; 15]>(b"this is a test\0")
    };
    let mut test2: [libc::c_char; 15] = unsafe {
        *::core::mem::transmute::<&[u8; 15], &mut [libc::c_char; 15]>(b"this is a tesu\0")
    };
    let mut test3: [libc::c_char; 16] = unsafe {
        *::core::mem::transmute::<&[u8; 16], &mut [libc::c_char; 16]>(b"this is a test \0")
    };
    let mut test4: [libc::c_char; 15] = unsafe {
        *::core::mem::transmute::<&[u8; 15], &mut [libc::c_char; 15]>(b"this is a test\0")
    };
    let mut test5: [libc::c_char; 15] = unsafe {
        *::core::mem::transmute::<&[u8; 15], &mut [libc::c_char; 15]>(b"This is a test\0")
    };

    unsafe {
        assert_ne!(
            string_hash(test1.as_mut_ptr() as *mut libc::c_void),
            string_hash(test2.as_mut_ptr() as *mut libc::c_void),
            "string_hash(test1) != string_hash(test2)"
        );
        assert_ne!(
            string_hash(test1.as_mut_ptr() as *mut libc::c_void),
            string_hash(test3.as_mut_ptr() as *mut libc::c_void),
            "string_hash(test1) != string_hash(test3)"
        );
        assert_ne!(
            string_hash(test1.as_mut_ptr() as *mut libc::c_void),
            string_hash(test5.as_mut_ptr() as *mut libc::c_void),
            "string_hash(test1) != string_hash(test5)"
        );
        assert_eq!(
            string_hash(test1.as_mut_ptr() as *mut libc::c_void),
            string_hash(test4.as_mut_ptr() as *mut libc::c_void),
            "string_hash(test1) == string_hash(test4)"
        );
    }
}
#[no_mangle]
pub extern "C" fn test_string_nocase_hash() {
    let mut test1: [libc::c_char; 15] = unsafe {
        *::core::mem::transmute::<&[u8; 15], &mut [libc::c_char; 15]>(b"this is a test\0")
    };
    let mut test2: [libc::c_char; 15] = unsafe {
        *::core::mem::transmute::<&[u8; 15], &mut [libc::c_char; 15]>(b"this is a tesu\0")
    };
    let mut test3: [libc::c_char; 16] = unsafe {
        *::core::mem::transmute::<&[u8; 16], &mut [libc::c_char; 16]>(b"this is a test \0")
    };
    let mut test4: [libc::c_char; 15] = unsafe {
        *::core::mem::transmute::<&[u8; 15], &mut [libc::c_char; 15]>(b"this is a test\0")
    };
    let mut test5: [libc::c_char; 15] = unsafe {
        *::core::mem::transmute::<&[u8; 15], &mut [libc::c_char; 15]>(b"This is a test\0")
    };

    unsafe {
        assert!(
            string_nocase_hash(test1.as_mut_ptr() as *mut libc::c_void)
                != string_nocase_hash(test2.as_mut_ptr() as *mut libc::c_void),
            "string_nocase_hash(test1) != string_nocase_hash(test2)"
        );
        assert!(
            string_nocase_hash(test1.as_mut_ptr() as *mut libc::c_void)
                != string_nocase_hash(test3.as_mut_ptr() as *mut libc::c_void),
            "string_nocase_hash(test1) != string_nocase_hash(test3)"
        );
        assert!(
            string_nocase_hash(test1.as_mut_ptr() as *mut libc::c_void)
                == string_nocase_hash(test5.as_mut_ptr() as *mut libc::c_void),
            "string_nocase_hash(test1) == string_nocase_hash(test5)"
        );
        assert!(
            string_nocase_hash(test1.as_mut_ptr() as *mut libc::c_void)
                == string_nocase_hash(test4.as_mut_ptr() as *mut libc::c_void),
            "string_nocase_hash(test1) == string_nocase_hash(test4)"
        );
    }
}
